﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
using SAASInvest.Contracts;

namespace SAASInvest.WebHost
{
    public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void UploadButton_Click(object sender, EventArgs e)
        {
            if (!String.IsNullOrEmpty(FileUpload1.FileName))
            {  
                string fileFullName = FileUpload1.FileName;
                int index = fileFullName.LastIndexOf("\\");
                string fileName = fileFullName.Substring(index + 1);
                //FileUpload1.SaveAs(Server.MapPath("~/Upload/" + fileName));
                
                var client = new Controller();
                {
                    FileUploadStream uploadData = new FileUploadStream()
                    {
                        UploadStream = FileUpload1.FileContent,
                        FileName = fileName
                    };
                    client.UploadFile(uploadData);
                }
            }
        }
    }
}